﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class PhoneDetail : System.Web.UI.Page
{
    public string styleProduct;
    private int PhoneId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.PhoneId = int.Parse(Request.QueryString["id"].ToString());
            Connection.cmd = new System.Data.SqlClient.SqlCommand("spGetPhoneById", Connection.GetConn());
            Connection.cmd.CommandType = System.Data.CommandType.StoredProcedure;
            Connection.cmd.Parameters.AddWithValue("@phoneId", PhoneId);
            SqlDataReader dr = Connection.cmd.ExecuteReader();
            
            try
            {
                dr.Read();
                hplPhone.Text = (String)dr["Name"];
                lblPhoneName.Text = dr["Name"].ToString();
                hplPhone.NavigateUrl = "~/PhoneDetail.aspx?id=" + dr["id"].ToString();
                imgAvatarPhone.ImageUrl = (String)dr["Img"];
                lblPrice.Text = dr["Price"].ToString() + " VND";
                lblCamera.Text = dr["Camera"].ToString();
                lblOs.Text = dr["Os"].ToString();
                lblBattery.Text = dr["Battery"].ToString();
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }
        }
    }

}
